package com.example.yichuangyun.mvvm.ui.activity.view;

import androidx.lifecycle.MutableLiveData;

import com.example.yichuangyun.config.Constant;
import com.example.yichuangyun.model.company.OutsideInvestDataModel;
import com.example.yichuangyun.mvvm.base.BaseViewModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseNetCallback;

import java.util.List;

public class OutsideInvestViewModel extends BaseViewModel {

    public MutableLiveData<List<OutsideInvestDataModel.OutsideInvestModel>> listMutableLiveData = new MutableLiveData<>();

    /**
     * 对外投资
     */
    public void getOutsideInvestInfo(String eid) {
        addSubscribe(mRetrofitHelper.getInvestment(eid).subscribeWith(new BaseNetCallback<List<OutsideInvestDataModel.OutsideInvestModel>>() {

            @Override
            public void onSuccess(BaseModel<List<OutsideInvestDataModel.OutsideInvestModel>> baseModel) {
                if (Constant.SUCCESS == baseModel.getCode()) {
                    if (null != baseModel.getData()) {
                        List<OutsideInvestDataModel.OutsideInvestModel> list = baseModel.getData();
                        listMutableLiveData.setValue(list);
                    }
                }
            }
        }));
    }
}
